# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=linphone
pkgver=5.2.86
pkgrel=0
pkgdesc="An opensource SIP phone for voice/video calls and instant messaging"
url="https://linphone.org/"
# riscv64 blocked by java -> belle-sip
arch="all !riscv64"
license="GPL-2.0-or-later"
options="!check" # no test available
# needed for linphonec
depends="belcard"
makedepends="
	bctoolbox-dev
	belcard-dev
	belle-sip-dev
	belr-dev
	cmake
	graphviz-dev
	libnotify-dev
	libxml2-dev
	libxv-dev
	mediastreamer2-dev
	ortp-dev
	readline-dev
	samurai
	speex-dev
	sqlite-dev
	v4l-utils-dev
	xerces-c-dev
	zlib-dev
	zxing-cpp-dev
	"
subpackages="$pkgname-dev $pkgname-libs"
source="https://gitlab.linphone.org/BC/public/liblinphone/-/archive/$pkgver/liblinphone-$pkgver.tar.gz
	cxx17.patch
	"
builddir="$srcdir/lib$pkgname-$pkgver"

build() {
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCMAKE_SKIP_RPATH=ON \
		-DENABLE_CONSOLE_UI=YES \
		-DENABLE_CXX_WRAPPER=NO \
		-DENABLE_DAEMON=YES \
		-DENABLE_DB_STORAGE=NO \
		-DENABLE_DOC=NO \
		-DENABLE_FLEXIAPI=NO \
		-DENABLE_GTK_UI=NO \
		-DENABLE_LIME=NO \
		-DENABLE_LIME_X3DH=NO \
		-DENABLE_NOTIFY=YES \
		-DENABLE_SHARED=YES \
		-DENABLE_STATIC=NO \
		-DENABLE_STRICT=NO \
		-DENABLE_STRICT=NO \
		-DENABLE_TOOLS=YES \
		-DENABLE_UNIT_TESTS=NO \
		-DENABLE_VCARD=YES \
		-DENABLE_VIDEO=YES
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

dev() {
	default_dev
	mkdir -p "$subpkgdir"/usr/lib/cmake/Linphone
	mv "$pkgdir"/usr/share/Linphone/cmake/* "$subpkgdir"/usr/lib/cmake/Linphone

	# Fix includes
	sed -i -e 's/INTERFACE_INCLUDE_DIRECTORIES.*/INTERFACE_INCLUDE_DIRECTORIES\  \"\/usr\/include\"/g' "$subpkgdir"/usr/lib/cmake/Linphone/LinphoneTargets.cmake
}

sha512sums="
d4fea5f3764373b9ca8e2292621fecc9d2ba01296fb2dcfae722668fc0fa9683ebf8fd274ff290a7db596359f1a143690edb4448d12d96f6b87b355b82a03f22  liblinphone-5.2.86.tar.gz
ec5832c6b6d596b51688918deeb4ca0cc4bbe90a217cdf88d39d799c2641078da5f24dc3048f3a8df1e43bb7a3107074244e0d052b52b9332553a1618b7a51f6  cxx17.patch
"
